package com.mall.controller;

import com.mall.result.Result;
import com.mall.service.CommonService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description: 通用接口
 * @author 勾新杰
 * @version 1.0
 * @date 2024/11/23 13:12
 */
@RestController
@RequestMapping("/common")
@RequiredArgsConstructor
@Tag(name = "通用接口", description = "通用接口")
public class CommonController {

    private final CommonService commonService;

    /**
     * 文件上传
     * @param file 文件
     * @return 文件url
     */
    @PostMapping("/upload")
    @Operation(summary = "文件上传")
    public Result<String> upload(MultipartFile file){
        String url = commonService.upload(file);
        return Result.success(url);
    }
}
